﻿//JumbotCms_4.1 Final
using System;
using JumbotCms.Common;

namespace JumbotCms.WebFile.MTag
{
    public partial class _create_index : JumbotCms.API.UserCenter
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            User_Load("", "html");
            if (q("act") != "save")
            {
                string PageStr = GetPageHtml("mtag_create");
                string cancreate = "0";
                doh.Reset();
                doh.ConditionExpress = "UserId=" + UserId;
                if (doh.Count("jcms_normal_mtag") < 3)
                    cancreate = "1";
                PageStr = PageStr.Replace("{$_cancreate$}", cancreate);
                Response.Write(PageStr);
            }
            else
            {
                if (!CheckFormUrl())
                    Response.End();
                if (f("txtTitle").Length > 0)
                {
                    doh.Reset();
                    doh.AddFieldItem("Title", f("txtTitle"));
                    doh.AddFieldItem("SortId", Str2Str(f("rblSortId")));
                    doh.AddFieldItem("Img", site.Dir + "user/otherfiles/image/nologo.jpg");
                    doh.AddFieldItem("JoinPower", 0);
                    doh.AddFieldItem("ViewPower", 0);
                    doh.AddFieldItem("CloseApply", 0);
                    doh.AddFieldItem("UserId", UserId);
                    doh.AddFieldItem("MemberTotal", 1);
                    int _newid = doh.Insert("jcms_normal_mtag");
                    doh.Reset();
                    doh.AddFieldItem("MTagId", _newid);
                    doh.AddFieldItem("Power", 9);
                    doh.AddFieldItem("UserId", UserId);
                    doh.Insert("jcms_normal_mtag_member");
                    Response.Write("location='" + site.Dir + "user/mtag';");
                }
                else
                    Response.Write("JumbotCms.Alert('提交有误', '0');");
            }
        }
    }
}
